#!/opt/bin/python2.6

import sys
sys.path.append("/volume1/dev/python/lib") 
import re,MySQLdb,mod_ced
from datetime import datetime, date, time

print "Content-Type: text/html"
print
print """
<!DOCTYPE html> 
<html>
<head>
        <title>Domotique Paillet</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
        <link rel="stylesheet" href="/media/css/ced_mobile.css" />
        <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
        <meta http-equiv="expires" content="0">
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache, must-revalidate"> 
</head>
<body>
<div>
"""
if  mod_ced.current_time >  mod_ced.force_time:
	print """<a href="" data-role="button" data-inline="true"  data-theme="b">Normal</a>
		<a href="mobile_force.cgi" data-role="button" data-inline="true">Forcer</a>
		"""
else:
	print """<a href="index.html" data-role="button" data-inline="true"  data-theme="b">Force """
	print  mod_ced.typejs[mod_ced.force.programme].name
	print """</a>
		<a href="mobile_modif_force.cgi" data-role="button" data-inline="true">normal</a>
		"""
print """
</div>
<div>
 <table data-role="table" id="movie-table-custom" data-mode="reflow" class="movie-list table-stroke">
              <thead>
                <tr>
                  <th>Piece</th>
                  <th>Current</th>
                  <th>Target</th>
                </tr>
              </thead>
              <tbody>
"""
for num_piece in  mod_ced.pieces.keys():
	print "<tr>"
	print "<td>"
	print """<a href="index.html" data-role="button"  data-mini="true">"""
	print mod_ced.pieces[num_piece].name
	print "</a>"
	print "</td>"
	print "<td>"
	print mod_ced.pieces[num_piece].target
	print "</td>"
	print "<td>"
	print mod_ced.pieces[num_piece].current
	print "</td>"
	print """<td>
<div data-role="controlgroup" data-type="horizontal" data-mini="true">
<a href="index.html" data-role="button">+</a>
<a href="index.html" data-role="button">-</a>
</div>
	</td>"""
	print "</tr>"
print """
              </tbody>
            </table>
</div>
</body>
</html>
"""
